package com.headFirstModel.iteratorPattern;

import java.util.Iterator;

/**
 * 服务员
 */
public class Waitress {
    Menu pancakeHouseMenu;
    Menu dineMenu;

    public Waitress(Menu pancakeHouseMenu,Menu dineMenu){
        this.pancakeHouseMenu=pancakeHouseMenu;
        this.dineMenu=dineMenu;
    }

    public void printMenu(){
        Iterator<MenuItem> pancakeIterator=pancakeHouseMenu.createIterator();
        Iterator<MenuItem> dinerIterator=dineMenu.createIterator();
        printMenu(pancakeIterator);
        printMenu(dinerIterator);
    }

    private void printMenu(Iterator<MenuItem> iterator) {
        while(iterator.hasNext()){
            MenuItem menuItem=(MenuItem)iterator.next();
            System.out.print(menuItem.getName()+",");
            System.out.print(menuItem.getPrice()+",");
            System.out.println(menuItem.getDescription());
        }
    }

    //其他方法

}
